﻿using System;
using Newtonsoft.Json;
using Volo.Abp.DependencyInjection;

namespace Joy.Erp.BasicArchives.Core.UniqueCodes
{
    public class TimeStampSegment : ISegment, ITransientDependency
    {
        protected TimeStampSegmentConfigrationObject ConfigrationObject { get; set; }

        public void Init(string configration)
        {
            ConfigrationObject = JsonConvert.DeserializeObject<TimeStampSegmentConfigrationObject>(configration);
        }

        public string GetCode(IUniqueCode entity)
        {
            return DateTime.Now.ToString(ConfigrationObject.Format);
        }
    }
}
